package com.azusa.xbiao.dao;

import com.azusa.xbiao.entity.Address;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface AddressDao extends JpaRepository<Address,Integer> {

    @Query("from Address where uId=?1 order by default desc ")
    List<Address> findByUserId(int uid);

    @Query("update Address set default=?2 where id=?1")
    @Modifying
    int updateByDefault(int id,int d);

    @Query("from Address where id=?1 and uId=?2")
    Address findByUIdAndId(int aid,int uid);
}
